/**
 * Created by cy on 2017/2/8.
 */
document.write("哈哈")

var i = 10;

if (i > 10) {
    document.write("i>10")
} else if (i < 10) {
    document.write("i<10")
} else {
    document.write("i==10")
}

var index = 1;
switch (index) {
    case 1:
        document.write("index=1");
        break
    case 2:
        document.write("index=2");
        break;
    default:
        document.write("default");
        break
}


var arr = [1, 2, 3, 4, 5, 6];

for (var j = 0; i = j < arr.length; j++) {
    document.write("<br/>j=" + j);
}

document.write("<br/>");

for (var j in arr) {
    document.write("<br/>j in arr=" + j);
}


do {
    document.write("<br/>index=" + index++);

    if (index == 50) {
        break;
    }
} while (index < 100);

while (index > 0) {
    index--;
    if (index % 2 != 0) {
        continue;
    }
    document.write("<br/>index=" + index);

}

//Javascript 对象定义

var file = {

    key: "value",
    "name": 1,
    document: "d",
    "path": "",
    "1d": ""
};

var obj = {
    p: function (x) {
        return 2 * x;
    }
}

// 对象的三种创建方式
// var obj0={}
//
// var obj1=new Object();
//
// var obj2=Object.create();


var people = {
    p1: "zs",
    p2: "ls"
}

//浏览器控制台输出
console.log(people.p1);
console.log(people["p2"])

//对象所有属性
var keys = Object.keys(people);

for (k in keys) {
    console.log("k=" + k)
}

delete people.p1;
console.log("=========================")
console.log(Object.keys(people))

console.log("=========================")

//如果没有该属性则会添加
people.p1 = "123";
people.p2 = "456";


console.log(people.p1);
console.log(people["p2"])

//修改指定对象内容
with (people) {

    people.p1 = "哈哈",
    people.p2 = "嘿嘿"
}
console.log(people.p1);
console.log(people["p2"])















